package com.punch.order.design.strategy;


import com.alibaba.fastjson.JSONObject;
import com.punch.common.dto.order.OrderDTO;
import com.punch.common.exception.BusinessException;
import com.punch.order.asyn.OrderAsync;
import com.punch.order.design.PayStrategy;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
@Slf4j
public class AliPayAppStrategy implements PayStrategy {


    @Resource
    @Lazy
    private OrderAsync orderAsync;

    /**
     * 生成统一签名订单信息
     *
     * @param orderDTO 订单信息
     * @return 订单信息
     */
    @Override
    public JSONObject payOrder(OrderDTO orderDTO) throws BusinessException {
        log.info("处理支付宝支付订单");
        //异步任务将未支付订单加入到动态定时任务
        orderAsync.addUnPayTask(orderDTO.getOrderId(), orderDTO.getCreateTime());
        return null;
    }

    /**
     * 支付回调
     *
     * @param request  请求
     * @param response 返回
     * @return string
     */
    @Override
    public String payNotify(HttpServletRequest request, HttpServletResponse response) throws BusinessException {
        return null;
    }
}
